﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bitcoin.Store
{
    public class MemoryWalletStore : IWalletStore
    {
        private readonly IDictionary<string, Wallet> _walletMap = new Dictionary<string, Wallet>();
        private object _lock = new object();

        public Wallet Load(string name)
        {
            lock (_lock)
            {
                // TODO: Serialize (e.g. to JSON string) and store that.

                Wallet wallet = null;
                _walletMap.TryGetValue(name, out wallet);
                return wallet;
            }
        }

        public void Save(string name, Wallet wallet)
        {
            lock (_lock)
            {
                _walletMap[name] = wallet;
            }
        }
    }
}
